From b0c41ad13b4919a2b5fd2c3ba269ef399d183e64 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 22 Jul 2005 11:29:15 +0000 Subject: [PATCH] * (bug 2885) Fix fatal errors and notices in PHP 5.1.0beta3 * (bug 2931) Fix additional notices on reference use in PHP 4.4.0 --- RELEASE-NOTES | 4 ++++ includes/Article.php | 5 +++-- includes/BagOStuff.php | 2 +- includes/Database.php | 7 +++++-- includes/DatabaseFunctions.php | 3 ++- includes/DifferenceEngine.php | 8 ++++---- includes/Linker.php | 6 +++--- includes/Namespace.php | 4 ++-- includes/ObjectCache.php | 11 +++++++---- includes/Parser.php | 2 +- includes/Revision.php | 32 ++++++++++++++++---------------- includes/SearchUpdate.php | 2 +- includes/SkinTemplate.php | 6 +++--- 13 files changed, 52 insertions(+), 40 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 7c1903af73..8e1a46d83c 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -587,6 +587,10 @@ of MediaWiki:Newpagetext) to &action=edit, if page is new. * Specify USE INDEX on Allpages chunk queries, sometimes gets lost due to bogus optimization * (bug 275) Section duplication fix +* Remove unused use of undefined variable in UserMailer +* Fix notice on search index update due to non-array +* (bug 2885) Fix fatal errors and notices in PHP 5.1.0beta3 +* (bug 2931) Fix additional notices on reference use in PHP 4.4.0 === Caveats === diff --git a/includes/Article.php b/includes/Article.php index 9a26a2e00c..3c1c3eb950 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -487,10 +487,11 @@ class Article { */ function &getDB() { #if ( $this->mForUpdate ) { - return wfGetDB( DB_MASTER ); + $ret =& wfGetDB( DB_MASTER ); #} else { - # return wfGetDB( DB_SLAVE ); + # $ret =& wfGetDB( DB_SLAVE ); #} + return $ret; } /** diff --git a/includes/BagOStuff.php b/includes/BagOStuff.php index 78ca5110b5..9ac3064a6b 100644 --- a/includes/BagOStuff.php +++ b/includes/BagOStuff.php @@ -359,7 +359,7 @@ class SqlBagOStuff extends BagOStuff { * @param string $serial * @return mixed */ - function &_unserialize( $serial ) { + function _unserialize( $serial ) { if( function_exists( 'gzinflate' ) ) { $decomp = @gzinflate( $serial ); if( false !== $decomp ) { diff --git a/includes/Database.php b/includes/Database.php index 16f277e299..69a3072dec 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -937,6 +937,9 @@ class Database { * @return string */ function makeUpdateOptions( $options ) { + if( !is_array( $options ) ) { + wfDebugDieBacktrace( 'makeUpdateOptions given non-array' ); + } $opts = array(); if ( in_array( 'LOW_PRIORITY', $options ) ) $opts[] = $this->lowPriorityOption(); @@ -1453,7 +1456,7 @@ class Database { /** * @todo document */ - function &resultObject( &$result ) { + function resultObject( &$result ) { if( empty( $result ) ) { return NULL; } else { @@ -1565,7 +1568,7 @@ class ResultWrapper { /** * @todo document */ - function &fetchObject() { + function fetchObject() { return $this->db->fetchObject( $this->result ); } diff --git a/includes/DatabaseFunctions.php b/includes/DatabaseFunctions.php index 772ca43e42..37059696e4 100644 --- a/includes/DatabaseFunctions.php +++ b/includes/DatabaseFunctions.php @@ -49,7 +49,8 @@ function wfSingleQuery( $sql, $dbi, $fname = '' ) { */ function &wfGetDB( $db = DB_LAST, $groups = array() ) { global $wgLoadBalancer; - return $wgLoadBalancer->getConnection( $db, true, $groups ); + $ret =& $wgLoadBalancer->getConnection( $db, true, $groups ); + return $ret; } /** diff --git a/includes/DifferenceEngine.php b/includes/DifferenceEngine.php index 24d076772a..e78fb87838 100644 --- a/includes/DifferenceEngine.php +++ b/includes/DifferenceEngine.php @@ -309,9 +309,9 @@ CONTROL; $dbr =& wfGetDB( DB_SLAVE ); if( $this->mNewid ) { - $this->newRev =& Revision::newFromId( $this->mNewid ); + $this->newRev = Revision::newFromId( $this->mNewid ); } else { - $this->newRev =& Revision::newFromTitle( $wgTitle ); + $this->newRev = Revision::newFromTitle( $wgTitle ); } if( is_null( $this->newRev ) ) { return false; @@ -332,9 +332,9 @@ CONTROL; } if( $this->mOldid ) { - $this->oldRev =& Revision::newFromId( $this->mOldid ); + $this->oldRev = Revision::newFromId( $this->mOldid ); } else { - $this->oldRev =& $this->newRev->getPrevious(); + $this->oldRev = $this->newRev->getPrevious(); $this->mOldid = $this->oldRev->getId(); } if( is_null( $this->oldRev ) ) { diff --git a/includes/Linker.php b/includes/Linker.php index 76ddde2a2f..6da46fdee5 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -130,7 +130,7 @@ class Linker { /** * Pass a title object, not a title string */ - function makeLinkObj( &$nt, $text= '', $query = '', $trail = '', $prefix = '' ) { + function makeLinkObj( $nt, $text= '', $query = '', $trail = '', $prefix = '' ) { global $wgOut, $wgUser; $fname = 'Linker::makeLinkObj'; wfProfileIn( $fname ); @@ -368,7 +368,7 @@ class Linker { } /** @todo document */ - function makeImageLinkObj( &$nt, $label, $alt, $align = '', $width = false, $height = false, $framed = false, + function makeImageLinkObj( $nt, $label, $alt, $align = '', $width = false, $height = false, $framed = false, $thumb = false, $manual_thumb = '' ) { global $wgContLang, $wgUser, $wgThumbLimits; @@ -546,7 +546,7 @@ class Linker { /** * Pass a title object, not a title string */ - function makeBrokenImageLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) { + function makeBrokenImageLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { # Fail gracefully if ( ! isset($nt) ) { # wfDebugDieBacktrace(); diff --git a/includes/Namespace.php b/includes/Namespace.php index a7345ebafa..d1d06aca06 100644 --- a/includes/Namespace.php +++ b/includes/Namespace.php @@ -100,7 +100,7 @@ class Namespace { /** * Returns the canonical (English Wikipedia) name for a given index */ - function &getCanonicalName( $index ) { + function getCanonicalName( $index ) { global $wgCanonicalNamespaceNames; return $wgCanonicalNamespaceNames[$index]; } @@ -109,7 +109,7 @@ class Namespace { * Returns the index for a given canonical name, or NULL * The input *must* be converted to lower case first */ - function &getCanonicalIndex( $name ) { + function getCanonicalIndex( $name ) { global $wgCanonicalNamespaceNames; static $xNamespaces = false; if ( $xNamespaces === false ) { diff --git a/includes/ObjectCache.php b/includes/ObjectCache.php index 5acf923b32..dbf6221c96 100644 --- a/includes/ObjectCache.php +++ b/includes/ObjectCache.php @@ -107,17 +107,20 @@ function &wfGetCache( $inputType ) { function &wfGetMainCache() { global $wgMainCacheType; - return wfGetCache( $wgMainCacheType ); + $ret =& wfGetCache( $wgMainCacheType ); + return $ret; } function &wfGetMessageCacheStorage() { global $wgMessageCacheType; - return wfGetCache( $wgMessageCacheType ); + $ret =& wfGetCache( $wgMessageCacheType ); + return $ret; } -function wfGetParserCacheStorage() { +function &wfGetParserCacheStorage() { global $wgParserCacheType; - return wfGetCache( $wgParserCacheType ); + $ret =& wfGetCache( $wgParserCacheType ); + return $ret; } ?> diff --git a/includes/Parser.php b/includes/Parser.php index c60a76bdf4..d851eb46d7 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -3373,7 +3373,7 @@ class ParserOptions function getUseDynamicDates() { return $this->mUseDynamicDates; } function getInterwikiMagic() { return $this->mInterwikiMagic; } function getAllowExternalImages() { return $this->mAllowExternalImages; } - function getSkin() { return $this->mSkin; } + function &getSkin() { return $this->mSkin; } function getDateFormat() { return $this->mDateFormat; } function getEditSection() { return $this->mEditSection; } function getNumberHeadings() { return $this->mNumberHeadings; } diff --git a/includes/Revision.php b/includes/Revision.php index 1905a269f9..e7e9b3ba44 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -21,7 +21,7 @@ class Revision { * @static * @access public */ - function &newFromId( $id ) { + function newFromId( $id ) { return Revision::newFromConds( array( 'page_id=rev_page', 'rev_id' => IntVal( $id ) ) ); @@ -38,7 +38,7 @@ class Revision { * @access public * @static */ - function &newFromTitle( &$title, $id = 0 ) { + function newFromTitle( &$title, $id = 0 ) { if( $id ) { $matchId = IntVal( $id ); } else { @@ -62,7 +62,7 @@ class Revision { * @return Revision * @access public */ - function &loadFromPageId( &$db, $pageid, $id = 0 ) { + function loadFromPageId( &$db, $pageid, $id = 0 ) { if( $id ) { $matchId = IntVal( $id ); } else { @@ -86,7 +86,7 @@ class Revision { * @return Revision * @access public */ - function &loadFromTitle( &$db, $title, $id = 0 ) { + function loadFromTitle( &$db, $title, $id = 0 ) { if( $id ) { $matchId = IntVal( $id ); } else { @@ -112,7 +112,7 @@ class Revision { * @access public * @static */ - function &loadFromTimestamp( &$db, &$title, $timestamp ) { + function loadFromTimestamp( &$db, &$title, $timestamp ) { return Revision::loadFromConds( $db, array( 'rev_timestamp' => $db->timestamp( $timestamp ), @@ -129,7 +129,7 @@ class Revision { * @static * @access private */ - function &newFromConds( $conditions ) { + function newFromConds( $conditions ) { $db =& wfGetDB( DB_SLAVE ); $row = Revision::loadFromConds( $db, $conditions ); if( is_null( $row ) ) { @@ -149,8 +149,8 @@ class Revision { * @static * @access private */ - function &loadFromConds( &$db, $conditions ) { - $res =& Revision::fetchFromConds( $db, $conditions ); + function loadFromConds( &$db, $conditions ) { + $res = Revision::fetchFromConds( $db, $conditions ); if( $res ) { $row = $res->fetchObject(); $res->free(); @@ -171,7 +171,7 @@ class Revision { * @static * @access public */ - function &fetchAllRevisions( &$title ) { + function fetchAllRevisions( &$title ) { return Revision::fetchFromConds( wfGetDB( DB_SLAVE ), array( 'page_namespace' => $title->getNamespace(), @@ -189,7 +189,7 @@ class Revision { * @static * @access public */ - function &fetchRevision( &$title ) { + function fetchRevision( &$title ) { return Revision::fetchFromConds( wfGetDB( DB_SLAVE ), array( 'rev_id=page_latest', @@ -209,7 +209,7 @@ class Revision { * @static * @access private */ - function &fetchFromConds( &$db, $conditions ) { + function fetchFromConds( &$db, $conditions ) { $res = $db->select( array( 'page', 'revision' ), array( 'page_namespace', @@ -301,7 +301,7 @@ class Revision { * Returns the title of the page associated with this entry. * @return Title */ - function &getTitle() { + function getTitle() { if( isset( $this->mTitle ) ) { return $this->mTitle; } @@ -313,7 +313,7 @@ class Revision { 'rev_id' => $this->mId ), 'Revision::getTItle' ); if( $row ) { - $this->mTitle =& Title::makeTitle( $row->page_namespace, + $this->mTitle = Title::makeTitle( $row->page_namespace, $row->page_title ); } return $this->mTitle; @@ -389,7 +389,7 @@ class Revision { /** * @return Revision */ - function &getPrevious() { + function getPrevious() { $prev = $this->mTitle->getPreviousRevisionID( $this->mId ); return Revision::newFromTitle( $this->mTitle, $prev ); } @@ -397,7 +397,7 @@ class Revision { /** * @return Revision */ - function &getNext() { + function getNext() { $next = $this->mTitle->getNextRevisionID( $this->mId ); return Revision::newFromTitle( $this->mTitle, $next ); } @@ -601,7 +601,7 @@ class Revision { * @param bool $minor * @return Revision */ - function &newNullRevision( &$dbw, $pageId, $summary, $minor ) { + function newNullRevision( &$dbw, $pageId, $summary, $minor ) { $fname = 'Revision::newNullRevision'; wfProfileIn( $fname ); diff --git a/includes/SearchUpdate.php b/includes/SearchUpdate.php index dc383fe188..d64d53d8a3 100644 --- a/includes/SearchUpdate.php +++ b/includes/SearchUpdate.php @@ -38,7 +38,7 @@ class SearchUpdate { wfProfileIn( $fname ); require_once( 'SearchEngine.php' ); - $search =& SearchEngine::create(); + $search = SearchEngine::create(); $lc = $search->legalSearchChars() . '&#;'; if( $this->mText === false ) { diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 20f017d44c..9ffb74d0c8 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -132,7 +132,7 @@ class SkinTemplate extends Skin { * @return object * @access private */ - function &setupTemplate( $classname, $repository=false, $cache_dir=false ) { + function setupTemplate( $classname, $repository=false, $cache_dir=false ) { return new $classname(); } @@ -161,7 +161,7 @@ class SkinTemplate extends Skin { $this->mTitle =& $wgTitle; $this->mUser =& $wgUser; - $tpl =& $this->setupTemplate( $this->template, 'skins' ); + $tpl = $this->setupTemplate( $this->template, 'skins' ); #if ( $wgUseDatabaseMessages ) { // uncomment this to fall back to GetText $tpl->setTranslator(new MediaWiki_I18N()); @@ -483,7 +483,7 @@ class SkinTemplate extends Skin { } - function tabAction( &$title, $message, $selected, $query='', $checkEdit=false ) { + function tabAction( $title, $message, $selected, $query='', $checkEdit=false ) { $classes = array(); if( $selected ) { $classes[] = 'selected'; -- 2.20.1